%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/functions/computed-column-forums-messages-with-many-transforms"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 9, 10, 44, 11, 13<br />2: PgSelect[8], PgSelect[18]<br />3: PgSelectRows[14], PgSelectRows[23]"):::bucket
    Bucket1("Bucket 1 (listItem)<br />Deps: 23<br /><br />ROOT __Item{1}ᐸ14ᐳ[15]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 16, 23<br /><br />ROOT PgSelectSingle{1}ᐸforumsᐳ[16]<br />1: <br />ᐳ: 17, 27<br />2: __ListTransform[22]<br />3: __ListTransform[30]<br />ᐳ: Lambda[34]"):::bucket
    Bucket3("Bucket 3 (subroutine)<br />Deps: 27<br /><br />ROOT Lambda{3}[29]"):::bucket
    Bucket4("Bucket 4 (subroutine)<br /><br />ROOT PgClassExpression{4}ᐸ__messages__.”featured”ᐳ[33]"):::bucket
    Bucket6("Bucket 6 (listItem)<br /><br />ROOT __Item{6}ᐸ34ᐳ[37]"):::bucket
    Bucket8("Bucket 8 (listItem)<br /><br />ROOT __Item{8}ᐸ37ᐳ[40]"):::bucket
    Bucket9("Bucket 9 (nullableBoundary)<br />Deps: 41<br /><br />ROOT PgSelectSingle{8}ᐸmessagesᐳ[41]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3 & Bucket4 & Bucket6
    Bucket6 --> Bucket8
    Bucket8 --> Bucket9

    %% plan dependencies
    PgSelect8[["PgSelect[8∈0] ➊<br />ᐸforumsᐳ"]]:::plan
    Object11{{"Object[11∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    Lambda13{{"Lambda[13∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[ undefined, 'INHERIT' ]ᐳ[44]"}}:::plan
    Object11 & Lambda13 --> PgSelect8
    Access9{{"Access[9∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access9 & Access10 --> Object11
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access9
    __Value2 --> Access10
    PgSelectRows14[["PgSelectRows[14∈0] ➊"]]:::plan
    PgSelect8 --> PgSelectRows14
    PgSelect18[["PgSelect[18∈0] ➊<br />ᐸmessagesᐳ"]]:::plan
    Object11 --> PgSelect18
    PgSelectRows23[["PgSelectRows[23∈0] ➊<br />Dependents: 2"]]:::plan
    PgSelect18 --> PgSelectRows23
    __Item15[/"__Item[15∈1]<br />ᐸ14ᐳ"\]:::itemplan
    PgSelectRows14 ==> __Item15
    PgSelectSingle16{{"PgSelectSingle[16∈1]<br />ᐸforumsᐳ"}}:::plan
    __Item15 --> PgSelectSingle16
    __ListTransform22[["__ListTransform[22∈2]<br />ᐸfilter:18ᐳ<br />More deps:<br />- PgSelectRows[23]"]]:::plan
    PgClassExpression27{{"PgClassExpression[27∈2]<br />ᐸ__forums__.”id”ᐳ"}}:::plan
    PgSelectSingle16 & PgClassExpression27 --> __ListTransform22
    PgClassExpression17{{"PgClassExpression[17∈2]<br />ᐸ__forums__.”name”ᐳ"}}:::plan
    PgSelectSingle16 --> PgClassExpression17
    PgSelectSingle16 --> PgClassExpression27
    __ListTransform30[["__ListTransform[30∈2]<br />ᐸgroupBy:22ᐳ"]]:::plan
    __ListTransform22 --> __ListTransform30
    Lambda34{{"Lambda[34∈2]"}}:::plan
    __ListTransform30 --> Lambda34
    List28{{"List[28∈3]<br />ᐸ26,27ᐳ"}}:::plan
    PgClassExpression26{{"PgClassExpression[26∈3]<br />ᐸ__messages__.”forum_id”ᐳ"}}:::plan
    PgClassExpression26 & PgClassExpression27 --> List28
    __Item24[/"__Item[24∈3]<br />ᐸ23ᐳ<br />More deps:<br />- PgSelectRows[23]"\]:::itemplan
    PgSelectSingle25{{"PgSelectSingle[25∈3]<br />ᐸmessagesᐳ"}}:::plan
    __Item24 --> PgSelectSingle25
    PgSelectSingle25 --> PgClassExpression26
    Lambda29{{"Lambda[29∈3]"}}:::plan
    List28 --> Lambda29
    __Item31[/"__Item[31∈4]<br />ᐸ22ᐳ"\]:::itemplan
    __ListTransform22 -.-> __Item31
    PgSelectSingle32{{"PgSelectSingle[32∈4]<br />ᐸmessagesᐳ"}}:::plan
    __Item31 --> PgSelectSingle32
    PgClassExpression33{{"PgClassExpression[33∈4]<br />ᐸ__messages__.”featured”ᐳ"}}:::plan
    PgSelectSingle32 --> PgClassExpression33
    __Item37[/"__Item[37∈6]<br />ᐸ34ᐳ"\]:::itemplan
    Lambda34 ==> __Item37
    __Item40[/"__Item[40∈8]<br />ᐸ37ᐳ"\]:::itemplan
    __Item37 ==> __Item40
    PgSelectSingle41{{"PgSelectSingle[41∈8]<br />ᐸmessagesᐳ"}}:::plan
    __Item40 --> PgSelectSingle41
    PgClassExpression42{{"PgClassExpression[42∈9]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgSelectSingle41 --> PgClassExpression42
    PgClassExpression43{{"PgClassExpression[43∈9]<br />ᐸ__messages__.”featured”ᐳ"}}:::plan
    PgClassExpression42 o--o PgClassExpression43

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect8,Access9,Access10,Object11,Lambda13,PgSelectRows14,PgSelect18,PgSelectRows23 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item15,PgSelectSingle16 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,PgClassExpression17,__ListTransform22,PgClassExpression27,__ListTransform30,Lambda34 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,__Item24,PgSelectSingle25,PgClassExpression26,List28,Lambda29 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,__Item31,PgSelectSingle32,PgClassExpression33 bucket4
    classDef bucket6 stroke:#ff1493
    class Bucket6,__Item37 bucket6
    classDef bucket8 stroke:#dda0dd
    class Bucket8,__Item40,PgSelectSingle41 bucket8
    classDef bucket9 stroke:#ff0000
    class Bucket9,PgClassExpression42,PgClassExpression43 bucket9

